/*
...rest  操作符：相当于合并

...扩展运算符    :展开，


const [a, ...other] = [12, 99, "abc", "ddd"]
console.log(other)
console.log(...other)
console.log([12, 99, "abc", "ddd"])
console.log(...[12, 99, "abc", "ddd"])
console.log(12, 99, "abc", "ddd")
// const all = document.querySelectorAll("*")
const arr = []
for(let item of all) {
	arr.push(item)
}
arr.push(123)
console.log(arr)

const all = [12, 99, "abc", "ddd"]
console.log([...all]) // 将类数组转成数组 & 数组浅拷贝
console.log([...all, ...all]) // 合并数组
// console.log(all)
// all.push(123)

console.log([..."hello world"]) // string -> array
console.log("hello world".split(""))
console.log("hello world".split("l"))

const all = document.querySelectorAll("*")
const linkeArray = {
	1: "abc",
	2: "ddd",
	0: "123",
	length: 3
}
// console.log(linkeArray)
// 将类数组转成数组
// es5
const arr = [].slice.call(linkeArray) // call 绑定 this 
arr.push("push")
console.log(arr)
// es6
// const arr1 = Array.from(all)
const arr1 = [...all]
arr1.push("push")
console.log(arr1)

// 将一组值转换为数组
console.log(Array.of(1, 2, "44", "abc"))
console.log(new Array(1, 2, "44", "abc"))
console.log([].concat(1, 2, "44", "abc"))

// console.log(arr.indexOf("a"))
const res = arr.find(function(item, index) {
	// console.log(item, index)
	// console.log(String(item).includes("a"))
	// break
	return String(item).includes("a")
})

const arr = [1, 2, 3, "abc", "b", "c"]
// const res = arr.find((item) => String(item).includes("a"))
// const res = arr.find((item) => typeof item === "string")
// const res = arr.find((item) => item === "c")
// const res = arr.findIndex((item) => item === "c")
const res = arr.findIndex((item) => String(item).includes("a"))
console.log(res)

// console.log(arr.fill("="))
// console.log(arr.fill(null))
// console.log(new Array(20).fill(undefined))
*/

const arr = [1, 2, 3, "abc", "b", "c"]
// arr.keys() // []
// for(let item of arr.keys()) {
// for(let item of arr.values()) {
for(let [index, item] of arr.entries()) {
	console.log(item)
}


const arr1 = [
	[1, 2],
	[11, 22, [123, "aaa"]],
	[111, 222],
]

console.log(arr1)
// console.log(arr1.flat())
// console.log(arr1.flat(2))
// console.log(arr1.flat(Infinity))




// ["b", "c", 3, "a", "b", "c"]
// console.log(arr.copyWithin(4))
// console.log(arr.copyWithin(0, 4))
// console.log(arr.copyWithin(0, -2))
// console.log(arr.copyWithin(2, -3))












